package com.aaa.ssm.service.impl;

import com.aaa.ssm.dao.PatientDao;
import com.aaa.ssm.entity.Patient;
import com.aaa.ssm.entity.SysUser;
import com.aaa.ssm.service.PatientService;
import com.aaa.ssm.util.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class PatientServiceImpl implements PatientService {
    @Resource
    private PatientDao patientDao;

    @Override
    public Patient checkUser(String userName, String password) {
        Patient patient=new Patient();
        patient.setUserName(userName);
        patient.setPassword(password);
        List<Patient> userList=patientDao.queryLogin(patient);
        if (userList!=null&&userList.size()>0){
            return userList.get(0);
        }
        return null;
    }

    @Override
    public PageInfo queryByPage(Page<Patient> page){
        //设值分页参数   startPage(int pageNum, int pageSize)  pageNum 第几页  pageSize 页面
        PageHelper.startPage(page.getPageNo(), page.getPageSize());
        return new PageInfo(patientDao.queryByParam(page.getData()));
    }
    @Override
    public List<Patient> queryByParam(Patient patient) {
        return patientDao.queryByParam(patient);
    }

    @Override
    public Patient queryById(int id) {
        return patientDao.queryById(id);
    }

    @Override
    public int add(Patient patient) {
        return patientDao.add(patient);
    }

    @Override
    public int update(Patient patient) {
        return patientDao.update(patient);
    }

    @Override
    public int delete(int id) {
        return patientDao.delete(id);
    }
}
